package presentation;

import javax.swing.JFrame;

import vo.SearchKeyVO;

public class AdvanceSearchModel {
	
	private AdvanceSearchFrame advanceSearchFrame;
	
	public AdvanceSearchModel(JFrame frame) {
		advanceSearchFrame = new AdvanceSearchFrame();
		advanceSearchFrame.setLocationRelativeTo(frame);
		advanceSearchFrame.setVisible(true);
	}
	
	public SearchKeyVO getSearchKeyVO() {
		while (true) {
			try {
				Thread.sleep(100);
			} catch (Exception e) {
				e.printStackTrace();
			}
			
			DialogEvent event = advanceSearchFrame.getEvent();
			if (event == null) {
				continue;
			}
			if (event == DialogEvent.CANCEL) {
				return null;
			}
			if (event == DialogEvent.CONFIRM) {
				return advanceSearchFrame.getSearchKeyVO();
			}
		}
	}

	public void disposeFrame() {
		advanceSearchFrame.dispose();
	}

}
